The powerPC version of MathPad can use 68K XFun code resources. It does this by using the emulator and converting between floating point formats. There is a speed penalty but it is handy to be able to use existing XFuns.
MathPad also allows native PPC external function code fragments. They are called CFuns to differentiate them from the 68K code resource XFuns. CFuns are somewhat easier to deal with than XFuns. The same set of callback routines are used. The code fragment manager links in the callback routines for you so there is no need to pass around a callback pointer. There is also no need to worry about A4 globals etc. The fragment's initialization routine calls back to MathPad and installs the function. No other entry point symbols to the fragment are used.
A CFun is a shared library fragment in a file of type 'CFun' and creator 'MPad'. MathPadPPC will load all the CFun frags it finds in the application's folder. As with XFuns, any named TEXT resources will be added to the Help menu.
CFuns use the file "callbackg.h" for prototypes of the callback routines. The MathPad application has export symbols for all callbacks. With CodeWarrior, the MathPad app can be included in the project to let the linker resolve the callbacks. For this trick to work you have to make sure the "Target" prefs are set so it will use the PEF importer on 'APPL' files.
To change a 68K XFun project to a PPC CFun:
1) Set project for PowerPC shared library. Creator 'MPad' type 'CFun'
2) Set linker Initialization entry symbol to InitCFun, no Main, no Termination
3) Change to PPC libraries. InterfaceLib, MathLib ...
4) Remove callbackg.c
5) Add MathPadPPC and set to use PEF importer on 'APPL' files.
6) Change entry point code. For example from "entry68K.c" to "entryPPC.c"
A "fat" XFun can be made by adding a 68K 'XFun' code resource to the CFun shared library fragment file. The 68K version of MathPad will find the 'XFun' resource and ignore the PPC code fragment. The PPC version will find the code fragment and ignore the 'XFun' resource.